﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace ClockwiseClient
{
    class ClassGraphTrade : ClassGraph
    {

        public override void Paint(Graphics g, Rectangle rect)
        {
            this.rect = rect;
            if (format.LineAlignment != StringAlignment.Center) format.LineAlignment = StringAlignment.Center;
            if (format.Alignment != StringAlignment.Center) format.Alignment = StringAlignment.Center;
            String tips = "显示区域太小了";
            stringSize = g.MeasureString(tips, font);
            if (rect.Width < 640 || rect.Height < 480)
            {
                if (stringSize.Width > rect.Width)
                {
                    tips = "太小了";
                    stringSize = g.MeasureString(tips, font);
                }
                if (stringSize.Width > rect.Width || stringSize.Height > rect.Height) return;
                PointF pointF = new PointF(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2 + stringSize.Height / 10);
                g.DrawString(tips, font, Brushes.Cyan, pointF, format);
                return;
            }
            ShowTrade(g, rect);
        }
        
        public override EnumGraph GetGraphType() { return EnumGraph.GRAPH_TRADE; }

        void ShowTrade(Graphics g, Rectangle rect)
        {
            ClassStockData classStockData = (ClassStockData)ClassStock.GetInstance();
            ClassFilter classFilter = classStockData.GetFilter();
            int idx = classStockData.focusStockIdx;
            if (classFilter != null) idx = classFilter.GetIndex(idx);
            string text;
            SizeF textSize;
            PointF pointF;
            text = "交易系统";
            textSize = g.MeasureString(text, fontTitle1);
            format.Alignment = StringAlignment.Near;
            int left = rect.Left + 4;
            pointF = new PointF(left, rect.Top + 4 + textSize.Height / 2 + textSize.Height / 10);
            g.DrawString(text, fontTitle1, Brushes.Yellow, pointF, format);
        }

    }
}
